#define _CRT_SECURE_NO_WARNINGS  1

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums)
    {
        vector<int> v;
        sort(nums.begin(), nums.end());
        int i = 0;
        while (i < nums.size() - 1)
        {
            if (nums[i] == nums[i + 1])
                i += 2;
            else
            {
                v.push_back(nums[i]);
                i += 1;
            }
        }
        if (i < nums.size())
        {
            v.push_back(nums[i]);
        }
        return v;
    }
};